package com.syt.hospital.controller;

import com.syt.hospital.service.impl.HospitalServiceImpl;
import com.syt.model.hospital.Hospital;
import com.syt.result.Result;
import com.syt.vo.hospital.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author: xxx
 * @Date: 2023/2/14 17:44
 * @Description: 医院管理
 */
@Api(tags = "医院管理")
@RestController
@RequestMapping("/admin/hospital/hospitalSet")
//@CrossOrigin 有 gateway 做了跨域
public class HospitalController {

    @Autowired
    private HospitalServiceImpl hospitalService;

    @ApiOperation(value = "医院详情信息")
    @GetMapping("/showHosDetail/{id}")
    public Result showHosDetail(@PathVariable String id){
        Map<String,Object> map=hospitalService.showHosDetail(id);
        return Result.ok(map);
    }

    @ApiOperation(value = "更新医院上线状态")
    @PatchMapping("/updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable String id, @PathVariable int status){
         hospitalService.updateHospStatus(id, status);
         return Result.ok();
    }

    @ApiOperation(value = "医院列表")
    @GetMapping("/list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page,
                           @PathVariable Integer limit,
                           HospitalQueryVo hospitalQueryVo){
        Page<Hospital> pageModel= hospitalService.selectHospPage(page, limit,hospitalQueryVo);
        return Result.ok(pageModel);
    }




}
